home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cfdemo / cfdemo.tx_ / cfdemo.tx
Encoding:
Text File  |  1998-11-13  |  5.0 KB  |  100 lines

  1. CHOOSEFONT API DEMO ⌐ Mike McGrath(UK)1998  emailto:mikem@clara.net
  2. ===================================================================
  3.  
  4. This demonstration illustrates the steps required by the windows font dialog box in allowing the
  5. user to select a font. These steps are normally automated but the demo now requires them  to be
  6. taken manually in order to understand them fully.
  7.  
  8. DECLARATION:
  9. ============
  10. Declare Function CHOOSEFONT Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As CHOOSEFONT) As Long
  11.  
  12.  
  13. VARIABLE STRUCTURE:
  14. ===================
  15. Public Type CHOOSEFONT
  16.         lStructSize As Long            '  sets size in bytes of variable structure
  17.         hwndOwner As Long              '  caller's window handle
  18.         hdc As Long                    '  printer DC/IC or NULL.................................ignore unless CF_PRINTERFONTS or CF_BOTH flags set
  19.         lpLogFont As String            '  ptr. to a LOGFONT struct if used.................set CF_INITTOLOGFONTSTRUCT to initialise
  20.         iPointSize As Long             '  size in points(*10) of selected font ...............sets this value after the user closes the dialog box.
  21.         flags As Long                  '  enum. type flags
  22.         rgbColors As Long              '  returned text color
  23.         lCustData As Long              '  data passed to hook fn...................................ignored unless the CF_ENABLEHOOK flag is set
  24.         lpfnHook As Long               '  ptr. to hook function.....................................ignored unless the CF_ENABLEHOOK flag is set
  25.         lpTemplateName As String       '  custom template name...................................ignored unless the CF_ENABLETEMPLATE flag is set
  26.         hInstance As Long              '  instance handle of.EXE that contains cust. dlg. template
  27.                                        '  ( If neither CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE is set, this member is ignored.)
  28.         lpszStyle As String            '  returns style field here must be LF_FACESIZE or bigger.........ignore unless CF_USESTYLE flag is set
  29.         nFontType As Integer           '  same value reported to the EnumFonts call back with the extra FONTTYPE_bits added
  30.         MISSING_ALIGNMENT As Integer
  31.         nSizeMin As Long               '  minimum pt size allowed &.......................................only if the CF_LIMITSIZE flag is specified.
  32.         nSizeMax As Long               '  max pt size allowed if  CF_LIMITSIZE is used.................only if the CF_LIMITSIZE flag is specified.
  33. End Type
  34.  
  35.  
  36. FLAGS:
  37. ======
  38. Public Const CF_SCREENFONTS = &H1
  39. Public Const CF_PRINTERFONTS = &H2
  40. Public Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS)
  41. Public Const CF_SHOWHELP = &H4&
  42. Public Const CF_ENABLEHOOK = &H8&
  43. Public Const CF_ENABLETEMPLATE = &H10&
  44. Public Const CF_ENABLETEMPLATEHANDLE = &H20&
  45. Public Const CF_INITTOLOGFONTSTRUCT = &H40&
  46. Public Const CF_USESTYLE = &H80&
  47. Public Const CF_EFFECTS = &H100&
  48. Public Const CF_APPLY = &H200&
  49. Public Const CF_ANSIONLY = &H400&
  50. Public Const CF_SCRIPTSONLY = CF_ANSIONLY
  51. Public Const CF_NOVECTORFONTS = &H800&
  52. Public Const CF_NOOEMFONTS = CF_NOVECTORFONTS
  53. Public Const CF_NOSIMULATIONS = &H1000&
  54. Public Const CF_LIMITSIZE = &H2000&
  55. Public Const CF_FIXEDPITCHONLY = &H4000&
  56. Public Const CF_WYSIWYG = &H8000 '  must also have CF_SCREENFONTS CF_PRINTERFONTS
  57. Public Const CF_FORCEFONTEXIST = &H10000
  58. Public Const CF_SCALABLEONLY = &H20000
  59. Public Const CF_TTONLY = &H40000
  60. Public Const CF_NOFACESEL = &H80000
  61. Public Const CF_NOSTYLESEL = &H100000
  62. Public Const CF_NOSIZESEL = &H200000
  63. Public Const CF_SELECTSCRIPT = &H400000
  64. Public Const CF_NOSCRIPTSEL = &H800000
  65. Public Const CF_NOVERTFONTS = &H1000000
  66.  
  67. Public Const SIMULATED_FONTTYPE = &H8000
  68. Public Const PRINTER_FONTTYPE = &H4000
  69. Public Const SCREEN_FONTTYPE = &H2000
  70. Public Const BOLD_FONTTYPE = &H100
  71. Public Const ITALIC_FONTTYPE = &H200
  72. Public Const REGULAR_FONTTYPE = &H400
  73.  
  74. VARIABLES:
  75. ==========
  76. Dim MyChooseFont As CHOOSEFONT
  77.  
  78. EXECUTION:
  79. ==========
  80. MyChooseFont.flags =CC_SCREENFONTS           (set flags,"OR" for joint flags)
  81. MyChooseFont.lStructSize = Len(MyChooseFont) (set size of variable structure) 
  82. MyChooseFont.hwndOwner = Form1.hWnd          (get handle of calling window)
  83. MyChooseFont.lpLogFont = space$(512)         (empty buffer to store font details) 
  84. MyChooseFont.nFontType =              (returns fonttype and bold/italic details)
  85. MyChooseFont.rgbColors =             (returns selected font color, 0 to 16777215)
  86.  
  87.  
  88. NOTES:
  89. ======
  90. To Install run setup.exe and to Uninstall use Add/remove programs facility in ControlPanel.
  91. CfDemo requires that you have vb40032.dll on your system.
  92. MyChooseFont.lplogfont is selected into a byte array only for demo purposes.
  93. Selected data is shown in yellow and  Returned data is shown in blue.
  94.  
  95. CHOOSEFONT API DEMO ⌐ Mike McGrath(UK)1998                  emailto:mikem@clara.net
  96. Permission is required for anything other than private use of this software and no liability 
  97. whatsoever will be accepted in connection with its use.  
  98.  
  99.  
  100.